#include <stdio.h>
#include <string.h>
#include <stdlib.h>


char* longestCommonPrefix(char** strs, int strsSize)
{
    char *ptr = malloc(sizeof(char)*strlen(strs[0]));
    strcpy(ptr,strs[0]);
    for(int i = 0;ptr[i] != '\0';i++)
    {
        for(int j = 0;j < strsSize;j++)
        {
            if(ptr[i] != strs[j][i])
            {
                ptr[i] = '\0';
                return ptr;
            }
        }
    }
    return ptr;
}

int main()
{
    char *strs[] = {"flow","flae","fleeg"};
    int strsSize = sizeof(strs)/sizeof(strs[0]);
    char *p = longestCommonPrefix(strs,strsSize);
    printf("%s\n",p);
    free(p);
    p = NULL;
    return 0;
}